<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/main.css" />
    <script type="text/javascript" src="../script/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../script/api.js"></script>
    <script type="text/javascript" src="../script/mobile.js"></script>
    <script type="text/javascript" src="../script/public.js"></script>
    <script type="text/javascript" src="../script/app.js"></script>
    <title>登录</title>
</head>
	<body>
		
		<div class="login_body">
			
			<div class="login_log">
                <span>
				    <img src="../image/kdc_logo.png">
                    <p>快点餐</p>
                </span>
			</div>

            <div class="userlg_info">
                <ul>
                    <li>
                        <p><img src="../image/user_in.png" alt=""></p>
                        <input type="text" name="username" placeholder="手机号或姓名">
                    </li>
                    <li>
                        <p><img src="../image/paswd_in.png" alt=""></p>
                        <input type="password" name="password" placeholder="请输入密码">
                    </li>
                </ul>
            </div>

            <div class="btn_lorr">

                <input type="button" onclick="login()" value="立即登录">
                <input type="button" onclick="regist()" value="注册">
            </div>
		</div>

        
	</body>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();

        apiready = function () {
            $api.fixStatusBar($api.dom('.header'));
            api.addEventListener({
                name: 'keyback'
            }, function(ret, err){
                api.closeWidget();
            });
            
            

        }

        //注册跳转
        function regist(){
            api.openWin({
                name:'registName',
                url:'./regist.html',
                reload:true,
                pageParam:{

                }
            });
        }

        //登录
        function login(){
            var did = api.deviceId;
            var username = $('input[name=username]').val();
            var password = $('input[name=password]').val();
            if (username =='') {
                api.alert({msg:"请输入手机号或者姓名"});return;
            }else if(password == ''){
                api.alert({msg:"请输入密码"});return;
            }
            var p = {username:username,password:password,did:did};
            api.ajax({
                url: webSiteUrl+'/app/public/login',
                method: 'post',
                data: {
                    
                    values: p
                }
            }, function(ret ,err) {
                

                if(ret.code==200){
                    
                   
                    $api.setStorage('user',ret.data);
                    // alert(JSON.stringify(data));return;

                    // alert(ret.msg);
                    
                    api.openWin({
                        name: 'slideName',
                        url: './index.html',
                        pageParam: {
                            name: 'text'
                        }
                    });
                   
                  
                }else{
                    alert(ret.msg)
                }
            });
        }
    </script>
</html>
